package com.jiangnan.artstudio.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.jiangnan.artstudio.MainActivity;
import com.jiangnan.artstudio.R;

public class MineSetUse extends BaseFragment {
    private TextView username,password,phoneNumber;
    private ImageView back;
    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.mine_set_zhgl,container,false);
        findViewId(view);
        initData();
        onClick();
        initTitle(view);
        return view;
    }

    public void initData() {
        username.setText(MainActivity.myAccount);
        String passwordTxt = MainActivity.myPassword;
        String xx = "";
        for(int i=0; i<passwordTxt.length(); i++) {
            xx += "*";
        }
        password.setText(xx);
        // 获取到号码后，切割号码到前三位和后四位
        String number = MainActivity.myPhoneNumber;
        phoneNumber.setText(number.substring(0,3) + "****" + number.substring(7,11));
    }

    public void onClick() {
        back.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                FragmentManager fm = getActivity().getSupportFragmentManager();
                fm.beginTransaction()
                        //替换为TwoFragment
                        .replace(R.id.main_content,new MineSet())
                        .commit();
            }
        });
    }

    private void findViewId(View view) {
        back = view.findViewById(R.id.zhgl_back);
        username = view.findViewById(R.id.set_username);
        password = view.findViewById(R.id.set_password);
        phoneNumber = view.findViewById(R.id.set_phoneNumber);
    }

}
